using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace JamD3
{
    public partial class Delimiter : Form
    {
        String _DelimiterString;
        public String DelimiterString
        {
            get { return _DelimiterString; }
            set { _DelimiterString = value; }
        }

        String[] SpinText = {
            "Newline", "\\n", "\\r" , ",", ";", ".", "_", "[space]"};
        String[] Values = {
            "\r\n", "\n", "\r", ",", ";", ".", "_", " "};


        public Delimiter()
        {
            InitializeComponent();
            foreach (String item in SpinText)
                dudPreset.Items.Add(item);
            dudPreset.Text = DelimiterString;
        }

        private void rbPreset_CheckedChanged(object sender, EventArgs e)
        {
            if (rbPreset.Checked)
            {
                dudPreset.Visible = true;
                dudPreset.Enabled = true;
                tbUserDefined.Visible = false;
                tbUserDefined.Enabled = false;

            }

            else
            {
                tbUserDefined.Visible = true;
                tbUserDefined.Enabled = true;
                dudPreset.Visible = false;
                dudPreset.Enabled = false;
            }
        }



        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (dudPreset.Enabled)
            {
                int x = 0;
                for (; x < SpinText.Length; x++)
                {
                    if (dudPreset.Text.Equals(SpinText[x]))
                    {
                        DelimiterString = Values[x];
                        break;
                    }
                }
                if (x == SpinText.Length)
                    DelimiterString = Values[0];
            }
            else
            {
                DelimiterString = tbUserDefined.Text;
            }
            this.DialogResult = DialogResult.OK;
            this.Close();
        }

        private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
            this.Close();
        }

    
    }
}